package com.zjitc;

import com.zjitc.obj.User;
import javax.jws.soap.SOAPBinding.Use;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/5 16:03
 * @description:
 */
public class App1 {

  public static void main(String[] args){
    User user = null;
    try{
      user = new User();
      user.init();
    }finally {
      if (user != null){
        user.close();
      }
    }
    ApplicationContext context = new ClassPathXmlApplicationContext("demo1.xml");
    User u1 = context.getBean("u1",User.class);
    User u2 = context.getBean("u2",User.class);
    User u3 = context.getBean("u3",User.class);
    User u4 = context.getBean("u4",User.class);

    if (u1.equals(u2)){
      System.out.println("u1 = u2");
    }
    System.out.println("u1 = " + u1);
    System.out.println("u2 = " + u2);
    System.out.println("u3 = " + u3);
    System.out.println("u4 = " + u4);

    ((ClassPathXmlApplicationContext)context).close();
  }
}
